home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 103 / MacAddict_103_2005-03.iso / Software / Internet & Communication / Salling Clicker 2.2.dmg / SallingClicker.pkg / Contents / Resources / preflight < prev    next >
Encoding:
Text File  |  2004-07-19  |  2.2 KB  |  56 lines

  1. #!/usr/bin/perl
  2. ########################################################################################
  3.  
  4.  
  5. # Make Clicker disconnect gracefully so as not to confuse the Bluetooth stack (we're also
  6. # trying the old dictionary style for disconnecting
  7. my $CLICKER_IS_RUNNING = 0;
  8. open(PSOUT, "/bin/ps -awwx |");
  9. while( <PSOUT> ) {
  10.     if( /SEC\ Helper\.app/ ) {
  11.         $CLICKER_IS_RUNNING = 1;
  12.     }
  13. }
  14. close(PSOUT);
  15. if(1 eq $CLICKER_IS_RUNNING) {
  16.     print "Telling SEC Helper to \"remove accessory menu\" with timeout of 10 seconds\n";
  17.     system("/usr/bin/osascript -e \'with timeout of 10 seconds\' -e \'tell application \"SEC Helper\"\' -e \'remove accessory menu\' -e \'end tell\' -e \'end timeout\' 2> /dev/null");
  18.     print "Telling SEC Helper to \"remove menu\" with timeout of 10s\n";
  19.     system("/usr/bin/osascript -e \'with timeout of 10 seconds\' -e \'tell application \"SEC Helper\"\' -e \'remove menu\' -e \'end tell\' -e \'end timeout\' 2> /dev/null");
  20.     sleep(2);
  21. }
  22.  
  23.  
  24. # Quit Clicker (we're also trying to killing the very first Clicker background app)
  25. open(PSOUT, "/bin/ps -awwx |");
  26. while( <PSOUT> ) {
  27.         if( /\s*(\d+)\s+.+SEC\ Helper\.app/ ) {
  28.                 print "Killing SEC Helper with PID = $1\n";
  29.                 kill 9, $1;
  30.         }
  31. }
  32. close(PSOUT);
  33.  
  34. open(PSOUT, "/bin/ps -awwx |");
  35. while( <PSOUT> ) {
  36.         if( /\s*(\d+)\s+.+ Sony\ Ericsson\ Clicker\ Helper\.app/ ) {
  37.                 print "Killing Sony Ericsson Clicker Helper with PID = $1\n";
  38.                 kill 9, $1;
  39.         }
  40. }
  41. close(PSOUT);
  42.  
  43. # Move the very old type of distribution out of the way, as Installer can't find it
  44. my $TEMP_DIR         = $ARGV[2] . "/private/tmp/tyuauehp7/";
  45. my $RECYCLYING         = $TEMP_DIR . "/OldSallingClicker/";
  46. mkdir $TEMP_DIR;
  47. mkdir $RECYCLYING;
  48. # Make sure the old helper application can't be started, as LaunchServices might choose it
  49. # over the new version otherwise. Could have used "rm", but this is safer:
  50. system("/bin/mv \"$ARGV[2]/Library/PreferencePanes/Sony Ericsson Clicker.prefPane\" \"$RECYCLYING\"");
  51. system("/bin/chmod a-x \"$RECYCLYING/Sony Ericsson Clicker.prefPane/Contents/MacOS/SEC Helper.app/Contents/MacOS/SEC Helper\"");
  52.  
  53. ########################################################################################
  54.  
  55. exit(0);
  56.